<%--
  Created by IntelliJ IDEA.
  User: teacher
  Date: 2023/10/24
  Time: 11:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户登录</title>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-3.4.1.min.js"></script>
    <script>
        $(function(){
            $("#codeImage").click(function(){
                // 修改图片地址时,如果还是原地址,图片不会刷新
                // 因此,我们必须使得修改后的地址与修改前的地址不一致
                // 完整url地址 协议名://域名:端口/应用名/访问命令[参数]
                $(this).attr("src","<%=request.getContextPath()%>/show.code?id="+new Date().getTime());
            });
        })
    </script>
</head>
<body>
<h1>用户登录</h1>
<hr>
<%--<form action="<%=request.getContextPath()%>/login2" method="post">--%>
<form action="<%=request.getContextPath()%>/login.code" method="post">
    用户名:<input type="text" name="username"><br>
    密&nbsp;&nbsp;&nbsp;码:<input type="password" name="password"><br>
    验证码:<input type="text" name="code">
    <a href="javascript:;"><img id="codeImage" src="<%=request.getContextPath()%>/show.code" alt="验证码加载失败"></a>
    <br>
    <input type="submit" value="登录">
    <span style="color:red;">
        <%
            String loginMsg = (String) request.getAttribute("loginMsg");
            if(loginMsg != null){
                out.print(loginMsg);
            }
        %>
    </span>
</form>
</body>
</html>
